import requests


"""
增加员工
resp = requests.post(url='https://heimahr.itheima.net/api/sys/user',
                     headers=head,
                     json={"username": "我不知道","mobile": "19211929667","formOfEmployment": 1,"workNumber": "","departmentId": 3,"timeOfEntry": "2020-01-01","correctionTime": "2020-01-04","staffPhoto": ""})
print(resp.text)

查询员工

修改员工
resp = requests.put(url="https://heimahr.itheima.net/api/sys/user/23",
                    headers=head,
                    json={
  "staffPhoto": "",
  "id": 23,
  "mobile": "19211929667",
  "username": "一个名字",
  "timeOfEntry": "2020-01-01",
  "workNumber": "23",
  "correctionTime": "2020-01-04",
  "departmentId": 3,
  "formOfEmployment": 1
})
print(resp.text)

"""
# 删除员工
# resp = requests.delete(url="https://heimahr.itheima.net/api/sys/user/23",
#                            headers=head)
# print(resp.text)

def post_newemp(head,emp_data):
    resp = requests.post(url='https://heimahr-t.itheima.net/api/sys/user',
                         headers=head,
                         json=emp_data)
    return resp


# https://heimahr-t.itheima.net/api/sys/user/4986
def get_empnews(head,id):
    resp = requests.get(url=f"https://heimahr-t.itheima.net/api/sys/user/{id}",
                        headers=head)
    return resp

def put_newmessage(id,head,json):
    resp = requests.put(url=f"https://heimahr-t.itheima.net/api/sys/user/{id}",
                        headers=head,
                        json=json)
    return resp

def delete_emp(id,head):
    resp = requests.delete(url=f"https://heimahr-t.itheima.net/api/sys/user/{id}",
                           headers=head)
    return resp
if __name__ == '__main__':
    head = {"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTc0NjcwMTQ3NywiZXhwIjoxNzQ2NzIzMDc3fQ.QPyAFlainwAuLmKjm9hn3GSURFBwD4kfZjIFzbGbJxc",
            'referer':'https://heimahr-t.itheima.net/employee/detail/4986'}
    resp = get_empnews(head,4986)
    print(resp.text)
